import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
import {HttpClient} from "@angular/common/http";

@Component({
  selector: 'app-edit-user',
  templateUrl: './edit-user.component.html',
  styleUrls: ['./edit-user.component.css']
})
export class EditUserComponent implements OnInit {
  registerForm: FormGroup  ;

  constructor(
    private readonly fb: FormBuilder,
    private readonly http: HttpClient
  ) {
    this.registerForm = this.fb.group({
      username: ['',Validators.required]
    })
  }

  ngOnInit(): void {

  }

  onSubmit() {
    // alert(JSON.stringify(this.registerForm.value ))
    this.http.post('/user',this.registerForm.value)
      .subscribe(result => alert(result));
  }
}
